package com.chalk.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.chalk.model.CoachAndSe;
import com.chalk.dao.CoachAndSeDao;
import com.chalk.service.CoachAndSeService;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author glq
 * @since 2020-12-21
 */

@Service
public class CoachAndSeServiceImpl extends ServiceImpl<CoachAndSeDao, CoachAndSe> implements CoachAndSeService {

    @Override
    public int addCoachAndSe(CoachAndSe entity) {
        return baseMapper.insert(entity);
    }

    @Override
    public int updateCoachAndSe(CoachAndSe entity) {
        return baseMapper.updateById(entity);
    }


    @Override
    public int deleteCoachAndSe(Integer id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public List<Integer> getCoachIdsBySeId(Integer seId) {
        EntityWrapper<CoachAndSe> wrapper = new EntityWrapper<>();
        wrapper.eq("se_id", seId);
        List<Integer> ids = new ArrayList<>();
        List<CoachAndSe> coachAndSeList = selectList(wrapper);
        for (CoachAndSe c : coachAndSeList) {
            ids.add(c.getCoachId());
        }
        return ids;
    }
}
